// 路由
import axios from 'axios'
// 设置基准路径
axios.defaults.baseURL = 'http://127.0.0.1:3000'
// 需要登陆 开启cookie的值
axios.defaults.withCredentials = true
export const getEmployeeLogin = (pa) => {
  return axios.post('/employee/employeeLogin', pa).then(
    res => {
      return res
    }
  )
}
// 用户模块_查询用户
export const selectUser = (pa) => {
  return axios.get('/user/queryUser', {params: pa}).then(
    res => {
      return res
    }
  )
}
// 用户模块_更新用户
export const updateUser = (pa) => {
  return axios.post('/user/updateUser', pa).then(
    res => {
      return res
    }
  )
}
// 查询一级列表
export const selectFirstList = (pa) => {
  return axios.get('/category/queryTopCategoryPaging', {params: pa}).then(res => {
    return res.data
  })
}

// 添加一级分类的列表
export const addFirstList = (pa) => {
  return axios.post('/category/addTopCategory', pa).then(res => {
    return res
  })
}

// 查询二级列表
export const selectSecondList = (pa) => {
  return axios.get('/category/querySecondCategoryPaging', {params: pa}).then(res => {
    return res.data
  })
}

// 查询商品列表
export const selectGoodManagaList = (pa) => {
  return axios.get('/product/queryProductDetailList', { params: pa }).then(res => {
    return res.data
  })
}
// 更新商品
export const updateGoods = (pa) => {
  return axios.post('/product/updateProduct', pa).then(res => {
    return res.data
  })
}

// 判断是否登陆
export const isLogin = () => {
  return axios.get('/employee/checkRootLogin').then(res => {
    return res.data
  })
}

// 编辑一级分类
export const editFirstCate = (pa) => {
  return axios.post('/category/updateTopCategory', pa).then(res => {
    return res.data
  })
}

// 添加二级分类
export const addSecondCate = (pa) => {
  return axios.post('/category/addSecondCategory', pa).then(res => {
    return res.data
  })
}

// 更新二级分类
export const updateSecondCate = (pa) => {
  return axios.post('/category/updateSecondCategory', pa).then(res => {
    return res
  })
}

// 添加商品
export const addProdunct = (pa) => {
  return axios.post('/product/addProduct', pa).then(res => {
    return res
  })
}

// 查询商品详情
export const selectDetail = (id) => {
  return axios.get('/product/queryProductDetail', {params: {id: id}}).then(res => {
    return res.data
  })
}
